﻿namespace PLCS.PlcInteraction.Models;

public class PLCReadDataWorkerDto
{
    public event EventHandler<string> CurrentValueChanged;

    /// <summary>
    /// 字段编号
    /// </summary>
    public string PLCReadDataNo { get; init; }

    /// <summary>
    /// Desc:最新数据
    /// Default:
    /// </summary>
    private string? _currentValue;

    public string? CurrentValue
    {
        get { return _currentValue; }
        set
        {
            if (_currentValue != value)
            {
                _currentValue = value;
                OnCurrentValueChanged(value);
            }
        }
    }

    protected void OnCurrentValueChanged(string newValue)
    {
        CurrentValueChanged?.Invoke(this, newValue);
    }

    /// <summary>
    /// 是否监听
    /// </summary>
    public YesNo IsDependency { get; set; }

    /// <summary>
    /// 关联的字段名
    /// </summary>
    public string? CorrespondingField { get; set; }

    /// <summary>
    /// 关联的字段名
    /// </summary>
    public string? CorrespondingTable { get; set; }

    /// <summary>
    /// 关联的类型
    /// </summary>
    public string? CorrespondingType { get; set; }

    /// <summary>
    /// 关联的Where字段名
    /// </summary>
    public string? WhereField { get; set; }

    /// <summary>
    /// 关联的where字段值
    /// </summary>
    public string? WhereValue { get; set; }
}